<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>2.初识vue组件</title>
        <!-- 引入Vue -->
        <script src="../js/vue.js"></script>
    </head>
    <body>
        <!-- 准备好一个容器-->
        <div id="app">
            <Student ></Student>
        </div>
    </body>

    <script>

        // 1. 在实例之前 创建组件  Vue.extend({})  
        let Student = Vue.extend({
            template:`
                <div>
                    <h1>{{uname}}</h1>
                    <h1>{{age}}</h1>
                    <h1>{{sex}}</h1>
                    <button @click="addAge">有过了一年</button>
                </div>
            `,
            data(){
                return {
                    uname:"张三",
                    age:18,
                    sex:"男"
                }
            },
            methods:{
                addAge(){
                    this.age ++;
                }
            }
        })

        //实例对象
        new Vue({
            el:"#app",
            components:{   //2. 注册组件
                Student
            }
           
        })




    </script>
</html>